﻿using B.W.passport.Application;
using B.W.passport.Application.breedService;
using B.W.passport.Application.DTO;
using B.W.passport.Domain;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.W.passport.API.Controllers
{
    /// <summary>
    /// 养殖控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BreedController : ControllerBase
    {
        private readonly IBreedService ibreedService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="ibreedService"></param>
        public BreedController(IBreedService ibreedService)
        {
            this.ibreedService = ibreedService;
        }
        /// <summary>
        /// 新增养殖信息
        /// </summary>
        /// <param name="breed"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddBreed(BreedDTO breed)
        {
            return await ibreedService.AddBreed(breed);
        }


        /// <summary>
        /// 获取所有养殖信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<Breed>> GetBreed(int id)
        {
            return await ibreedService.GetBreed(id);    
        }

        /// <summary>
        /// 商品修改
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdateBreed(BreedDTO breed)
        {
            return await ibreedService.UpdateBreed(breed);
        }
    }
}
